extends VBoxContainer



onready var paragraph = $TabContainer/Paragraph
onready var select_paragraph = $TabContainer/SelectParagraph
onready var content_input = $"TabContainer/对话内容#/TextEdit"



# 切换显示
func _on_Button_button_up():
	$TabContainer.visible = !$TabContainer.visible


func _on_TextEdit_text_changed():
	$HBoxContainer/Label.text = str(get_index()+1, ". ", content_input.text)
	


func set_data(data):
	if data:
		content_input.text = data["content"]
		$HBoxContainer/Label.text = str(get_index()+1, ". ", data["content"]) 
		
		paragraph.set_data(data.get("paragraph", null))
		select_paragraph.set_data(data.get("select_paragraph", null))
	


func get_data():
	var data = {
		"content": content_input.text,
		"paragraph": paragraph.get_data(),
		"select_paragraph": select_paragraph.get_data(),
	}
	
	return data
	


# 通过内容得到标题
func get_title(content):
	if content:
		if content.length() > 30:
			return content
		else:
			return content
	else:
		return "" 


func _on_delButton_button_up():	
	MainTool.confirm("你是否确认删除对话: %s" % content_input.text,self,"_on_del_ok")
	

func _on_del_ok(data):
	queue_free()
